<div class="page-crumb">
	<div class="ui-ctrl ui-crumb"><span class="ui-crumb-node ui-crumb-node-first ui-crumb-node-last">修改广告物料</span></div>
</div>

<div class="layui-main">
	<form class="layui-form" action="" onsubmit="return false">
		 <input type="hidden" name="id" value="{$ad['id']}">
		<div class="layui-form-item">
			<label class="layui-form-label">物料名称：</label>
			<div class="layui-input-inline">
				<input type="text" name="ad_name" lay-verify="ad_name" autocomplete="off" placeholder="" class="layui-input" value="{$ad['ad_name']}">
			</div>
			<div class="layui-form-mid layui-word-aux">最多可输入100个字符</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">是否添加水印</label>
			<div class="layui-input-block">
				<input checked="" name="open" lay-skin="switch" lay-filter="watermark" lay-text="开启|关闭" type="checkbox" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">图片文件：</label>
			<div class="layui-input-inline">
				<span class="layui-file-upload" id="uploadImage">上传图片</span>
			</div>
			<input type="hidden" name="image_url" lay-verify="image_url" class="image_url" value={$ad.image_url}>
		</div>
	
		<div class="layui-form-item">
			<label class="layui-form-label">图片尺寸：</label>
			<div class="layui-input-inner">
				<label class="inner-label">宽度：</label>
				<input class="layui-input ad_width" lay-verify="ad_width" style="width: 60px;" type="text" value="{$ad['ad_width']}" name="ad_width">
				<label class="suffix-hint">px</label>
			</div>
			<div class="layui-input-inner">
				<label class="inner-label">高度：</label>
				<input class="layui-input ad_height" lay-verify="ad_height" style="width: 60px;" type="text" value="{$ad['ad_height']}" name="ad_height">
				<label class="suffix-hint">px</label>
			</div>
		</div>
   		<div class="layui-form-item">
			<label class="layui-form-label">图片标题：</label>
			<div class="layui-input-inline">
				<input type="text" name="image_title" lay-verify="image_title" autocomplete="off" placeholder="" class="layui-input" value="{$ad['image_title']}">
			</div>
			<div class="layui-form-mid layui-word-aux">最多可输入100个字符</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">图片描述：</label>
			<div class="layui-input-inline">
				<input type="text" name="image_describe" lay-verify="image_describe" autocomplete="off" placeholder="" class="layui-input" value="{$ad['image_describe']}">
			</div>
			<div class="layui-form-mid layui-word-aux">最多可输入100个字符</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">游戏试玩：</label>
			<div class="layui-input-block">
				<input type="radio" name="is_game" lay-filter="is_game" value="0" data-state="no"  title="否" <?php if($ad['is_game'] == '0') echo 'checked="checked"'; ?>>
				<input type="radio" name="is_game" lay-filter="is_game" value="1" data-state="yes"  title="是" <?php if($ad['is_game'] == '1') echo 'checked="checked"'; ?>>
			</div>
		</div>

		<style>
			.game-box {
				display: block;
			}
		</style>

		<?php
			$className = $styleShow = '';
				$state = [

					0 =>	'no',
					1 =>	'yes',
			];

			if( isset($state[$ad['is_game']]) ) {
			$className = 'state-' . $state[$ad['is_game']];
			$styleShow = 'style="display:block"';
			}

		?>

		<div class="layui-form-item game-false">
			<label class="layui-form-label">点击链接：</label>
			<div class="layui-input-inline">
				<input type="text" name="show_link" lay-verify="show_link" autocomplete="off" placeholder="" class="layui-input" value="{$ad['show_link']}">
			</div>
			<div class="layui-form-mid layui-word-aux">最多可输入1000个字符</div>
		</div>

		<div class="layui-form-item game-box {$className}" {$styleShow}>
			<label class="layui-form-label">游戏列表：</label>
			<div class="layui-input-block">
				<input type="radio" name="is_game_list" lay-filter="is_game_list" value="0" title="否" <?php if($ad['is_game_list'] == '0') echo 'checked="checked"'; ?> >
				<input type="radio" name="is_game_list" lay-filter="is_game_list" value="1" title="是" <?php if($ad['is_game_list'] == '1') echo 'checked="checked"'; ?> >
			</div>
		</div>

		<div class="layui-form-item  game-box {$className}" {$styleShow} >
			<label class="layui-form-label">游戏id</label>
			<div class="layui-input-inline">
				<select multiple="multiple" name="game_id" lay-verify="game_id" lay-filter="game_id" id="select2" style="width: 300px;height:160px;" lay-ignore name="">
					<foreach name="cgame" item="v" key="k">
						<option value="{$v.id}" selected>{$v.game_name} | {$v.g_id}</option>
					</foreach>
				</select>
				<div>
					<input type="button" value="移除" id="remove">
					<input type="button" value="全部移除" id="remove_all">

				</div>
				<!--<input type="text" name="game_id" lay-verify="game_id" autocomplete="off" placeholder="" class="layui-input">-->
			</div>

		</div>

		<div class="layui-form-item game-box {$className}" {$styleShow}>
			<label class="layui-form-label ">选择游戏：</label>
			<div class="layui-input-inline">
				<select multiple="multiple" id="select1"  lay-ignore style="width:300px;height:160px;">
					<foreach name="game" item="v" key="k">
						<option value="{$v.id}">{$v.game_name} | {$v.g_id}</option>
					</foreach>
				</select>
				<div>
					<input type="button" value="全部添加"  id="add_all">
					<input type="button" value="添加"  id="add">

				</div>
			</div>
		</div>


		<div class="layui-input-inline">

		</div>

	<!--	<div class="layui-form-item  game-box {$className}" {$styleShow}>
			<label class="layui-form-label">游戏id</label>
			<div class="layui-input-inline">
				<input type="text" name="game_id" lay-verify="game_id" autocomplete="off" placeholder="" class="layui-input" value="{$ad['game_id']}">
			</div>
			<div class="layui-form-mid layui-word-aux">最多可输入1000个字符</div>
		</div>-->

		<div class="layui-form-item">
		    <label class="layui-form-label">目标窗口：</label>
		    <div class="layui-input-block">
		      <input type="radio" name="target" value="1" title="新窗口" <?php if($ad['target'] == '1') echo 
			  'checked="checked"'; ?> >
		      <input type="radio" name="target" value="2" title="原窗口" <?php if($ad['target'] == '2') echo 
			  'checked="checked"'; ?> >
		    </div>
		</div>
		
		<div class="layui-form-item">
			<div class="layui-input-block">
			  <button class="layui-btn" lay-submit="" lay-filter="submit">　　保存　　</button>
			  <button class="layui-btn layui-btn-primary close-btn" onclick="PopModel.closeFrame();">取消</button>
			</div>
		</div>
	</form>
	<div class="form-preview-wrapper">
		<div class="preview-content"><img src="{$ad.image_url}"></div>
	</div>
</div>
<script src="__BACKEND_STATIC__/js/plupload.full.min.js"></script>
<script src="__BACKEND_STATIC__/js/ad/edit.js"></script>
<script type="text/javascript">
    //移到右边
    $('#add').click(function(){
        //获取选中的选项，删除并追加给对方
        $('#select1 option:selected').appendTo('#select2');
    });

    //移到左边
    $('#remove').click(function(){
        $('#select2 option:selected').appendTo('#select1');
    });

    //全部移到右边
    $('#add_all').click(function(){
        //获取全部的选项,删除并追加给对方
        $('#select1 option').appendTo('#select2');
    });

    //全部移到左边
    $('#remove_all').click(function(){
        $('#select2 option').appendTo('#select1');
    });

    //双击选项
    $('#select1').dblclick(function(){ //绑定双击事件
        //获取全部的选项,删除并追加给对方
        $("option:selected",this).appendTo('#select2'); //追加给对方
    });

    //双击选项
    $('#select2').dblclick(function(){
        $("option:selected",this).appendTo('#select1');
    });
</script>

